package com.twoGroup.boot.pojo;

import java.util.ArrayList;

public class Page<T> {
    //当前页
    private Integer pageNow;
    //总页码
    private Integer pageTotal;
    //当前页显示的数量
    private Integer pageSize;
    //总记录数
    private Integer pageTotalCount;
    //当前开始值
    private Integer start;
    //当前页数据
    private ArrayList<T> list;

    public ArrayList<T> getList() {
        return list;
    }

    public void setList(ArrayList<T> list) {
        this.list = list;
    }

    public Integer getPageNow() {
        if(pageNow<1){
            pageNow=1;
        }
        if(pageNow>pageTotal){
            pageNow=pageTotal; }
        return pageNow;
    }

    public void setPageNow(Integer pageNow) {
        this.pageNow = pageNow;
    }

    public Integer getPageTotal() {
        pageTotal=pageTotalCount/pageSize;
        return pageTotalCount%pageSize==0? pageTotal:pageTotal+1;
    }

    public void setPageTotal(Integer pageTotal) {
        this.pageTotal = pageTotal;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getPageTotalCount() {
        return pageTotalCount;
    }

    public void setPageTotalCount(Integer pageTotalCount) {
        this.pageTotalCount = pageTotalCount;
    }

    public Integer getStart() {
        start=(pageNow-1)*pageSize;
        return start;
    }

    public void setStart(Integer start) {
        this.start = start;
    }

    @Override
    public String toString() {
        return "Page{" +
                "pageNow=" + pageNow +
                ", pageTotal=" + pageTotal +
                ", pageSize=" + pageSize +
                ", pageTotalCount=" + pageTotalCount +
                ", start=" + start +
                '}';
    }
}


